angular.module("driver").controller("MoreCtrl", ['$scope', '$meteor',
  '$rootScope', '$state', '$ionicPopup', '$cordovaSocialSharing',
  function($scope, $meteor, $rootScope, $state, $ionicPopup,
    $cordovaSocialSharing) {

    $scope.request = function() {
      if (!Meteor.user()) {
        //throw new Meteor.Error("未登录！", "必须先登录！");
        var alertPopup = $ionicPopup.alert({
          title: '温馨提示',
          template: '请您先登录！',
          okType: 'button-royal',
          okText: '确定'
        });
        alertPopup.then(function(res) {
          $state.go('account');
        });
        return false;
      } else {
        $state.go('onesdata');
      }
    };

    $scope.share = function() {
      $cordovaSocialSharing
        .share('驾驾', null, '/logo.png', 'http://fir.im/jiajia')
        .then(function(result) {

        }, function(err) {

        });
    };


    $scope.phoneud = function() {
      //console.log(request[0]);

      var confirmPopup = $ionicPopup.confirm({
        title: '123-4567-890',
        //template: '123-4567-890',
        cancelText: '取消',
        cancelType: 'button-royal button-outline',
        okText: '呼叫',
        okType: 'button-assertive button-outline',
      });
      confirmPopup.then(function(res) {
        if (res) {
          console.log('呼叫');
        } else {
          console.log('取消');
        }
      });
    };
  }
]);
